package com.example.happyhome;

import android.app.Fragment;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.Toast;
import androidx.recyclerview.widget.RecyclerView;

import androidx.appcompat.widget.AppCompatRatingBar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.tabs.TabLayout;

public class MainActivity extends Activity {


    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        //底部导航栏
        ImageView imageView1 = (ImageView) findViewById(R.id.home);
        ImageView imageView2 = (ImageView) findViewById(R.id.color);
        ImageView imageView3 = (ImageView) findViewById(R.id.suggest);
        ImageView imageView4 = (ImageView) findViewById(R.id.user);
        imageView1.setOnClickListener(l);
        imageView2.setOnClickListener(l);
        imageView3.setOnClickListener(l);
        imageView4.setOnClickListener(l);
    }

    View.OnClickListener l = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction ft = fragmentManager.beginTransaction();
            Fragment f = null;
            switch (v.getId()) {
                case R.id.home:
                    f = new homefragment();
                    break;
                case R.id.color:
                    f = new colorfragment();
                    break;
                case R.id.suggest:
                    f = new suggestfragment();
                    break;
                case R.id.user:
                    f = new userfragment();
                    break;
                default:
                    break;
            }

            ft.replace(R.id.fragment, f);
            ft.commit();
        }
    };
   /* ImageButton more = (ImageButton) findViewById(R.id.img1);
        more.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this,userfragment.class);
            startActivity(intent);
        }
    });
    ImageButton massage = (ImageButton) findViewById(R.id.imgxinxi);
        massage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this,Introduction.class);
            startActivity(intent);
        }
    });
}*/
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);

        return true;

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int itemId = item.getItemId();
        switch (itemId) {
            case R.id.listview_vertical_stander:
                Log.d(TAG, "点击了Listview效果里的垂直标准");
                break;
            case R.id.listview_vertical_back:
                Log.d(TAG, "点击了Listview效果里的垂直反向");
                break;
            case R.id.listview_horizont_stander:
                Log.d(TAG, "点击了Listview效果里的水平标准");
                break;
            case R.id.listview_horizonta_back:
                Log.d(TAG, "点击了Listview效果里的水平反向");
                break;

        }
        return super.onOptionsItemSelected(item);
    }
}












